﻿<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>DR钻戒后台管理系统</title>
    <link rel="stylesheet" href="css/public.css"/>
    <link rel="stylesheet" href="css/style.css"/>
    <script src="../js/jquery-1.12.4.js"></script>
</head>

<script type="text/javascript">

    function UpdateAdminInfo(id){
        let goodspath=$("#goodspath").val();
        let path="/images/"+goodspath
        let series=$("#series").val();
        let style=$("#style").val();
        let texture=$("#texture").val();
        let shape=$("#shape").val();
        let type=$("#type").val();
        let colour=$("#colour").val();
        let carat=$("#carat").val();
        let diamondPrice=$("#diamondPrice").val();
        var seSeries = document.getElementById("series")
        var seStyle = document.getElementById("style")
        var seTexture = document.getElementById("texture")
        var seShape = document.getElementById("shape")
        var seType = document.getElementById("type")
        var seColour = document.getElementById("colour")

        if (seSeries.value==0) {
            alert("请选择系列!")
            return false;
        }
        if (seStyle.value==0) {
            alert("请选择款式!")
            return false;
        }
        if (seTexture.value==0) {
            alert("请选择材质!")
            return false;
        }
        if (seShape.value==0) {
            alert("请选择形状!")
            return false;
        }
        if (seType.value==0) {
            alert("请选择类型!")
            return false;
        }
        if (seColour.value==0) {
            alert("请选择色彩度!")
            return false;
        }
        if ($('#carat').val() == ''||$('#carat').val() == null) {
            alert("请填写克拉!")
            return false;
        }
        if ($('#diamondPrice').val() == ''||$('#diamondPrice').val() == null) {
            alert("请填写价格!")
            return false;
        }

        $.post("http://localhost:8080/DiamondRing/BackUpdateGoodsInfoServlet","ID="+id+"&goodspath="+path+"&series="+series+"&style="+style+"&texture="+texture+"&shape="+shape+"&type="+type+"&colour="+colour+"&carat="+carat+"&diamondPrice="+diamondPrice,function (data) {
            if (data>0){
                alert("保存成功!");
                location.href="http://localhost:8080/DiamondRing/back-stage-Management/providerList.html";
            }else{
                alert("保存失败!");
            }
        })
    }

    $(function () {
        let id=sessionStorage.getItem("ID")
        $.getJSON("http://localhost:8080/DiamondRing/BackLookGoodsInfoServlet","ID="+id,function (data) {
            $.each(data, function () {
                $(".providerAdd").append("<form action=\"#\">\n" +
                    "                <!--div的class 为error是验证错误，ok是验证成功-->\n" +
                    "                <div>\n" +
                    "                    <label ><strong>钻戒原图片：</strong></label>\n" +
                    "                <img width='80px' height='80px' src="+"../"+this.goodsPath+"><br/>\n"+
                    "                </div>\n" +
                    "                <div>\n" +
                    "                    <label ><strong>请选择图片：</strong></label>\n" +
                    "                <input type=\"file\" id=\"goodspath\" name=\"test\">\n"+
                    "                </div>\n" +
                    "                <div>\n" +
                    "                    <label ><strong>钻戒系列：</strong></label>\n" +
                    "                <select name=\"series\" id=\"series\">\n" +
                    "                    <option value=\"0\" selected>原系列:"+this.series+"</option>\n" +
                    "                    <option value=\"1\">稀世粉钻系列</option>\n" +
                    "                    <option value=\"2\">Forever系列</option>\n" +
                    "                    <option value=\"3\">My Heart系列</option>\n" +
                    "                    <option value=\"4\">True Love系列</option>\n" +
                    "                    <option value=\"5\">I Swear系列</option>\n" +
                    "                    <option value=\"6\">Just you系列</option>\n" +
                    "                </select>\n" +
                    "                </div>\n" +
                    "\n" +
                    "                <div>\n" +
                    "                    <label ><strong>钻戒款式：</strong></label>\n" +
                    "                    <select name=\"style\" id=\"style\">\n" +
                    "                        <option value=\"0\" selected>原款式:"+this.style+"</option>\n" +
                    "                        <option value=\"1\">经典款</option>\n" +
                    "                        <option value=\"2\">简奢款</option>\n" +
                    "                        <option value=\"3\">心相恋</option>\n" +
                    "                        <option value=\"4\">心相随</option>\n" +
                    "                        <option value=\"5\">情缘一生</option>\n" +
                    "                        <option value=\"6\">情缘心动</option>\n" +
                    "                        <option value=\"7\">典雅款</option>\n" +
                    "                        <option value=\"8\">相许</option>\n" +
                    "                        <option value=\"9\">简华款</option>\n" +
                    "                        <option value=\"10\">挚爱款</option>\n" +
                    "                        <option value=\"11\">一生相伴</option>\n" +
                    "                        <option value=\"12\">永恒之心</option>\n" +
                    "                    </select>\n" +
                    "                </div>\n" +
                    "\n" +
                    "                <div>\n" +
                    "                    <label ><strong>钻戒材质：</strong></label>\n" +
                    "                    <select name=\"texture\" id=\"texture\">\n" +
                    "                        <option value=\"0\" selected>原材质:"+this.texture+"</option>\n" +
                    "                        <option value=\"1\">18k白金</option>\n" +
                    "                        <option value=\"2\">18k黄金</option>\n" +
                    "                        <option value=\"3\">PT950</option>\n" +
                    "                        <option value=\"4\">18k玫瑰金</option>\n" +
                    "                    </select>\n" +
                    "                </div>\n" +
                    "\n" +
                    "                <div>\n" +
                    "                    <label ><strong>钻戒形状：</strong></label>\n" +
                    "                    <select name=\"shape\" id=\"shape\">\n" +
                    "                        <option value=\"0\" selected>原形状:"+this.shape+"</option>\n" +
                    "                        <option value=\"1\">圆形</option>\n" +
                    "                        <option value=\"2\">心形</option>\n" +
                    "                        <option value=\"3\">方形</option>\n" +
                    "                        <option value=\"4\">心形(双心)</option>\n" +
                    "                    </select>\n" +
                    "                </div>\n" +
                    "\n" +
                    "                <div>\n" +
                    "                    <label ><strong>钻戒类型：</strong></label>\n" +
                    "                    <select name=\"type\" id=\"type\">\n" +
                    "                        <option value=\"0\" selected>原类型:"+this.type+"</option>\n" +
                    "                        <option value=\"1\">对戒</option>\n" +
                    "                        <option value=\"2\">吊坠</option>\n" +
                    "                        <option value=\"3\">方形</option>\n" +
                    "                        <option value=\"4\">项链</option>\n" +
                    "                        <option value=\"5\">手链</option>\n" +
                    "                        <option value=\"6\">单戒</option>\n" +
                    "                    </select>\n" +
                    "                </div>\n" +
                    "\n" +
                    "                <div>\n" +
                    "                    <label ><strong>钻戒色彩度：</strong></label>\n" +
                    "                    <select name=\"colour\" id=\"colour\">\n" +
                    "                        <option value=\"0\" selected>原色彩度:"+this.colour+"</option>\n" +
                    "                        <option value=\"1\">D色</option>\n" +
                    "                        <option value=\"2\">E色</option>\n" +
                    "                        <option value=\"3\">F色</option>\n" +
                    "                        <option value=\"4\">G-H色</option>\n" +
                    "                        <option value=\"6\">I-J色</option>\n" +
                    "                        <option value=\"6\">K-M色</option>\n" +
                    "                        <option value=\"7\">N-Z色</option>\n" +
                    "                    </select>\n" +
                    "                </div>\n" +
                    "\n" +
                    "                <div>\n" +
                    "                    <label ><strong>钻戒克拉：</strong></label>\n" +
                    "                    <input type=\"text\" id=\"carat\" value=\"原克拉:"+this.carat+"\">\n" +
                    "                </div>\n" +
                    "\n" +
                    "                <div>\n" +
                    "                    <label ><strong>钻戒价格：</strong></label>\n" +
                    "                    <input type=\"text\" id=\"diamondPrice\" value=\"原价格:"+this.diamondPrice+"\">\n" +
                    "                </div>\n" +
                    "\n" +
                    "                <div class=\"providerAddBtn\">\n" +
                    "                    <a href=\"javascript:void(0)\" onclick='UpdateAdminInfo("+this.id+")'>保存</a>\n" +
                    "                    <a href=\"providerList.html\">返回</a>\n" +
                    "                </div>\n" +
                    "            </form>")
            })
        })
    });

</script>
<body>
<!--头部-->
<header class="publicHeader">
    <h1>DR钻戒后台管理系统</h1>

    <div class="publicHeaderR">
        <a href="login.html">退出</a>
        
</header>
<!--时间-->
<section class="publicTime">
    <span id="time">2015年1月1日 11:11  星期一</span>
    <a href="#">温馨提示：为了能正常浏览，请使用高版本浏览器!</a>
</section>
<!--主体内容-->
<section class="publicMian ">
    <div class="left">
        <h2 class="leftH2"><span class="span1"></span>功能列表 <span></span></h2>
        <nav>
            <ul class="list">
                <li><a href="billList.html">订单管理</a></li>
                <li id="active"><a href="providerList.html">商品管理</a></li>
                <li><a href="userList.html">用户管理</a></li>
                <li><a href="password.html">密码修改</a></li>
                <li><a href="login.html">退出系统</a></li>
            </ul>
        </nav>
    </div>
    <div class="right">
        <div class="location">
            <strong>你现在所在的位置是:</strong>
            <span>供应商管理页面 >> 供应商修改页</span>
        </div>
        <div class="providerAdd">
        </div>

    </div>
</section>
<footer class="footer">
</footer>
<script src="js/time.js"></script>

</body>
</html>